package io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;

public class FlujoSalidaImpl<T> implements FlujoSalida<T> {
	
	private PrintStream ps;
	
	public FlujoSalidaImpl(){
		ps=System.out;
	}
	
	public FlujoSalidaImpl(String nombre) throws FileNotFoundException {
		if (nombre.equals("")){
			ps=System.out;
		}else {
			ps=new PrintStream(new File(nombre));
		}
	}
	public void imprimeIterable(Iterable<T>it, String separador){
		for(T cad : it){
			  ps.print(cad + separador);
			}
		}
	
	public void imprime(T cad){
		ps.print(cad.toString());
	}
	public void imprime(T cad, String separador){
		ps.print(cad.toString()+separador);
	}
	
	public void imprimeLinea(T linea){
		ps.println(linea.toString());
	}
	public void imprimeIterable(Iterable<T>it){
		for(T cad : it){
		  ps.print(cad);
		}
	}
	
	public void imprimeLineaIterable(Iterable<T>it){
		for(T cad : it){
			ps.println(cad);
		}
	}

}
